#include "widget.h"
#include "ui_widget.h"

#include <QButtonGroup>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //创建group分组
    QButtonGroup*group1=new QButtonGroup(this);
    QButtonGroup*group2=new QButtonGroup(this);
    QButtonGroup*group3=new QButtonGroup(this);

    //把单选按钮放入不同组里
    group1->addButton(ui->radioButton1_1);
    group1->addButton(ui->radioButton1_2);
    group1->addButton(ui->radioButton1_3);

    group2->addButton(ui->radioButton2_1);
    group2->addButton(ui->radioButton2_2);
    group2->addButton(ui->radioButton2_3);

    group3->addButton(ui->radioButton3_1);
    group3->addButton(ui->radioButton3_2);
    group3->addButton(ui->radioButton3_3);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_radioButton1_1_clicked()
{
    ui->label_1->setText(ui->radioButton1_1->text());
}


void Widget::on_radioButton1_2_clicked()
{
    ui->label_1->setText(ui->radioButton1_2->text());
}

void Widget::on_radioButton1_3_clicked()
{
    ui->label_1->setText(ui->radioButton1_3->text());
}

void Widget::on_radioButton2_1_clicked()
{
    ui->label_2->setText(ui->radioButton2_1->text());
}

void Widget::on_radioButton2_2_clicked()
{
    ui->label_2->setText(ui->radioButton2_2->text());
}

void Widget::on_radioButton2_3_clicked()
{
    ui->label_2->setText(ui->radioButton2_3->text());
}

void Widget::on_radioButton3_1_clicked()
{
    ui->label_3->setText(ui->radioButton3_1->text());
}

void Widget::on_radioButton3_2_clicked()
{
    ui->label_3->setText(ui->radioButton3_2->text());
}

void Widget::on_radioButton3_3_clicked()
{
    ui->label_3->setText(ui->radioButton3_3->text());
}

void Widget::on_checkBox_stateChanged(int arg1)
{
    if(arg1==Qt::Checked)
    {
        ui->label_4->setText(ui->label_4->text() + ui->checkBox->text());
    }
    else
    {
        ui->label_4->setText("");
    }
}

void Widget::on_checkBox_2_stateChanged(int arg1)
{
    if(arg1==Qt::Checked)
    {
        ui->label_4->setText(ui->label_4->text() + ui->checkBox_2->text());
    }
    else
    {
        ui->label_4->setText("");
    }
}

void Widget::on_checkBox_3_stateChanged(int arg1)
{
    if(arg1==Qt::Checked)
    {
        ui->label_4->setText(ui->label_4->text() + ui->checkBox_3->text());
    }
    else
    {
        ui->label_4->setText("");
    }
}
